package com.zhgxi.security.entity;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Proxy;

import com.zhgxi.core.orm.hibernate.BaseEntity;

@Entity
@Table(name = "users")
@Proxy(lazy = false)  
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Users extends BaseEntity {

	private String account;
	private String password;
	private boolean enable;

	@ManyToMany(targetEntity = Roles.class, fetch = FetchType.EAGER)  
    @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "uid"), inverseJoinColumns = @JoinColumn(name = "rid"))  
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) 
	private Set<Roles> roles;

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Set<Roles> getRoles() {
		return roles;
	}

	public void setRoles(Set<Roles> roles) {
		this.roles = roles;
	}

}
